Hints
Matlab programming
Your task to implement a function which computes the
n-region sign chart of a polynomial.Hints
This question is similar to the previous sign chart question, so you could use your solution to that one as a starting point for this one. However, because on this exercise the number of zeros is not fixed at 2, you will need to use a different technique to iterate over the regions, such as a loop.
If
v is a vector then v(1) and v(end) are the first and last elements of x, respectively.Matlab programming
Your task to implement a function which computes the
n-region sign chart of a polynomial.Hints
This question is similar to the previous sign chart question, so you could use your solution to that one as a starting point for this one. However, because on this exercise the number of zeros is not fixed at 2, you will need to use a different technique to iterate over the regions, such as a loop.
If
v is a vector then v(1) and v(end) are the first and last elements of x, respectively.Matlab programming
Your task to implement a function which computes the
n-region sign chart of a polynomial.This question is similar to the previous sign chart question, so you could use your solution to that one as a starting point for this one. However, because on this exercise the number of zeros is not fixed at 2, you will need to use a different technique to iterate over the regions, such as a loop.
If
v is a vector then v(1) and v(end) are the first and last elements of x, respectively.Solution
verbose = 0; if ( verbose ) timestamp ( ); fprintf ( 1, \'\ \' ); fprintf ( 1, \'DIAPHONY:\ \' ); fprintf ( 1, \' MATLAB version\ \' ); fprintf ( 1, \' Compute the diaphony of a point set.\ \' ); end % % Get the filename. % if ( nargin < 1 ) fprintf ( 1, \'\ \' ); input_filename = input ( \'Enter the name of the input file.\' ); end % % Get the data size. % [ dim_num, point_num ] = r8mat_header_read ( input_filename ); if ( verbose ) fprintf ( 1, \'\ \' ); fprintf ( 1, \' The spatial dimension is %d\ \', dim_num ); fprintf ( 1, \' The number of points is %d\ \', point_num ); end % % Read the data. % points = r8mat_data_read ( input_filename, dim_num, point_num ); if ( min ( min ( points ) ) < 0.0 ) fprintf ( 1, \'\ \' ); fprintf ( 1, \'DIAPHONY - Fatal error!\ \' ); fprintf ( 1, \' At least one coordinate of a point is less than 0!\ \' ); error ( \'DIAPHONY - Fatal error!\' ) elseif ( 1.0 < max ( max ( points ) ) ) fprintf ( 1, \'\ \' ); fprintf ( 1, \'DIAPHONY - Fatal error!\ \' ); fprintf ( 1, \' At least one coordinate of a point is greater than 1!\ \' ); error ( \'DIAPHONY - Fatal error!\' ) end % % Analyze the data. % d = diaphony_compute ( dim_num, point_num, points ); e = 1.0 / sqrt ( point_num ); de = d / e; fprintf ( 1, \'\ \' ); fprintf ( 1, \' File M N Diaphony 1/sqrt(N) D/sqrt(N)\ \' ); fprintf ( 1, \' %s %2d %5d %14.6g %14.6g %14.6g\ \', ... input_filename, dim_num, point_num, d, e, de ); % % Terminate. % if ( verbose ) fprintf ( 1, \'\ \' ); fprintf ( 1, \'DIAPHONY:\ \' ); fprintf ( 1, \' Normal end of execution.\ \' ); fprintf ( 1, \'\ \' ); timestamp ( ) end return end function d = diaphony_compute ( dim_num, point_num, x )